<?php

namespace App\Exports;

use App\Models\UserModels\Models\UserModel;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
use Maatwebsite\Excel\Concerns\WithTitle;

class InvoicesExport
    implements FromQuery, WithStrictNullComparison, WithCustomStartCell, WithHeadings, ShouldQueue,
    WithMultipleSheets, WithTitle
{
    use Exportable;
    protected $invoices;
    public $startCell;
    public $headings;
    public function __construct( $invoices, array $headings, $startCell = 'A1')
    {
        $this->invoices = $invoices;
        $this->startCell = $startCell;
        $this->headings = $headings;
    }

//    public function array(): array
//    {
//        return $this->invoices;
//    }

    /**
     * 开始单元格
     * @return string
     */
    public function startCell(): string
    {
        return $this->startCell;
    }

    /**
     * 添加标题
     * @return array
     */
    public function headings(): array
    {
        return $this->headings;
    }

    public $query;
    public function query()
    {
        $this->query = (new UserModel())::query()
            ->where('id', '=', '1')->limit(1000);
        return $this->query;
        // TODO: Implement query() method.
    }

    public function sheets(): array
    {
        return [
            0 => $this->query,
            1 => $this->query
        ];
        // TODO: Implement sheets() method.
    }

    public function title(): string
    {
        return 'Month ';
    }
}
